﻿using System;
using System.Collections.Generic;
using System.Linq;
using Helpers;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.Extensions;
using TaleWorlds.CampaignSystem.GameMenus;
using TaleWorlds.CampaignSystem.GameState;
using TaleWorlds.CampaignSystem.MapEvents;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.LinQuick;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.Issues
{
	// Token: 0x02000306 RID: 774
	public class GangLeaderNeedsToOffloadStolenGoodsIssueBehavior : CampaignBehaviorBase
	{
		// Token: 0x06002D13 RID: 11539 RVA: 0x000BCD4D File Offset: 0x000BAF4D
		public override void RegisterEvents()
		{
			CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener(this, new Action<Hero>(this.OnCheckForIssue));
		}

		// Token: 0x06002D14 RID: 11540 RVA: 0x000BCD66 File Offset: 0x000BAF66
		public override void SyncData(IDataStore dataStore)
		{
		}

		// Token: 0x06002D15 RID: 11541 RVA: 0x000BCD68 File Offset: 0x000BAF68
		private bool ConditionsHold(Hero issueGiver, out Settlement selectedHideout)
		{
			selectedHideout = null;
			bool flag = issueGiver.IsGangLeader && issueGiver.CurrentSettlement.Town.Security < 70f && issueGiver.CurrentSettlement.Notables.Any((Hero x) => x.CharacterObject.IsHero && x.CharacterObject.HeroObject != issueGiver && x.CharacterObject.HeroObject.IsMerchant);
			selectedHideout = ((issueGiver.CurrentSettlement != null && issueGiver.CurrentSettlement.IsTown) ? GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.FindSuitableHideout(issueGiver.CurrentSettlement) : null);
			return flag && selectedHideout != null;
		}

		// Token: 0x06002D16 RID: 11542 RVA: 0x000BCE10 File Offset: 0x000BB010
		public void OnCheckForIssue(Hero hero)
		{
			Settlement relatedObject;
			Campaign.Current.IssueManager.AddPotentialIssueData(hero, this.ConditionsHold(hero, out relatedObject) ? new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(this.OnSelected), typeof(GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue), IssueBase.IssueFrequency.Common, relatedObject) : new PotentialIssueData(typeof(GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue), IssueBase.IssueFrequency.Common));
		}

		// Token: 0x06002D17 RID: 11543 RVA: 0x000BCE68 File Offset: 0x000BB068
		private static Settlement FindSuitableHideout(Settlement settlement)
		{
			Settlement result = null;
			float num = float.MaxValue;
			foreach (Hideout hideout in from t in Campaign.Current.AllHideouts
			where t.IsInfested
			select t)
			{
				if (!Campaign.Current.BusyHideouts.Contains(hideout.Settlement))
				{
					float num2 = hideout.Settlement.GatePosition.DistanceSquared(settlement.Position2D);
					if (num2 <= 3600f && num2 < num)
					{
						num = num2;
						result = hideout.Settlement;
					}
				}
			}
			return result;
		}

		// Token: 0x06002D18 RID: 11544 RVA: 0x000BCF2C File Offset: 0x000BB12C
		private IssueBase OnSelected(in PotentialIssueData pid, Hero issueOwner)
		{
			PotentialIssueData potentialIssueData = pid;
			return new GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue(issueOwner, potentialIssueData.RelatedObject as Settlement);
		}

		// Token: 0x04000D81 RID: 3457
		private const int IssueDuration = 15;

		// Token: 0x04000D82 RID: 3458
		private const int MaxHideoutDistance = 60;

		// Token: 0x04000D83 RID: 3459
		private const IssueBase.IssueFrequency GangLeaderNeedsToOffloadStolenGoodsIssueFrequency = IssueBase.IssueFrequency.Common;

		// Token: 0x02000622 RID: 1570
		public class GangLeaderNeedsToOffloadStolenGoodsIssue : IssueBase
		{
			// Token: 0x06004B70 RID: 19312 RVA: 0x0015B4EA File Offset: 0x001596EA
			internal static void AutoGeneratedStaticCollectObjectsGangLeaderNeedsToOffloadStolenGoodsIssue(object o, List<object> collectedObjects)
			{
				((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004B71 RID: 19313 RVA: 0x0015B4F8 File Offset: 0x001596F8
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._issueHideout);
				collectedObjects.Add(this.CounterOfferHero);
			}

			// Token: 0x06004B72 RID: 19314 RVA: 0x0015B519 File Offset: 0x00159719
			internal static object AutoGeneratedGetMemberValueCounterOfferHero(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue)o).CounterOfferHero;
			}

			// Token: 0x06004B73 RID: 19315 RVA: 0x0015B526 File Offset: 0x00159726
			internal static object AutoGeneratedGetMemberValue_randomForStolenTradeGood(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue)o)._randomForStolenTradeGood;
			}

			// Token: 0x06004B74 RID: 19316 RVA: 0x0015B538 File Offset: 0x00159738
			internal static object AutoGeneratedGetMemberValue_issueHideout(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue)o)._issueHideout;
			}

			// Token: 0x17000F3D RID: 3901
			// (get) Token: 0x06004B75 RID: 19317 RVA: 0x0015B545 File Offset: 0x00159745
			private ItemObject StolenTradeGood
			{
				get
				{
					return Game.Current.ObjectManager.GetObject<ItemObject>(GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue.PossibleStolenItems[this._randomForStolenTradeGood]);
				}
			}

			// Token: 0x17000F3E RID: 3902
			// (get) Token: 0x06004B76 RID: 19318 RVA: 0x0015B562 File Offset: 0x00159762
			private int StolenTradeGoodAmount
			{
				get
				{
					return MathF.Ceiling(10000f / (float)base.IssueOwner.CurrentSettlement.Town.GetItemPrice(this.StolenTradeGood, null, false) * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F3F RID: 3903
			// (get) Token: 0x06004B77 RID: 19319 RVA: 0x0015B594 File Offset: 0x00159794
			private int StolenTradeGoodPrice
			{
				get
				{
					return MathF.Round((float)base.IssueOwner.CurrentSettlement.Town.GetItemPrice(this.StolenTradeGood, null, false) * 0.5f * (float)this.StolenTradeGoodAmount);
				}
			}

			// Token: 0x17000F40 RID: 3904
			// (get) Token: 0x06004B78 RID: 19320 RVA: 0x0015B5C7 File Offset: 0x001597C7
			protected override int RewardGold
			{
				get
				{
					return MathF.Round((float)base.IssueOwner.CurrentSettlement.Town.GetItemPrice(this.StolenTradeGood, null, false) * 0.4f * (float)this.StolenTradeGoodAmount);
				}
			}

			// Token: 0x17000F41 RID: 3905
			// (get) Token: 0x06004B79 RID: 19321 RVA: 0x0015B5FA File Offset: 0x001597FA
			// (set) Token: 0x06004B7A RID: 19322 RVA: 0x0015B602 File Offset: 0x00159802
			[SaveableProperty(10)]
			public override Hero CounterOfferHero { get; protected set; }

			// Token: 0x17000F42 RID: 3906
			// (get) Token: 0x06004B7B RID: 19323 RVA: 0x0015B60B File Offset: 0x0015980B
			public override bool IsThereAlternativeSolution
			{
				get
				{
					return true;
				}
			}

			// Token: 0x17000F43 RID: 3907
			// (get) Token: 0x06004B7C RID: 19324 RVA: 0x0015B60E File Offset: 0x0015980E
			protected override bool IssueQuestCanBeDuplicated
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000F44 RID: 3908
			// (get) Token: 0x06004B7D RID: 19325 RVA: 0x0015B611 File Offset: 0x00159811
			public override TextObject IssueAlternativeSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=cODzH0Ke}Well, if you don't want to go yourself to meet them, I'm sure you can send a trusted aide with 10 or so men to load and guard those {STOLEN_GOODS_SIZE} {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%}. I am sure our people can seal the deal by themselves.", null);
					textObject.SetTextVariable("STOLEN_GOODS_SIZE", this.StolenTradeGoodAmount);
					textObject.SetTextVariable("STOLEN_GOOD", this.StolenTradeGood.Name);
					return textObject;
				}
			}

			// Token: 0x17000F45 RID: 3909
			// (get) Token: 0x06004B7E RID: 19326 RVA: 0x0015B647 File Offset: 0x00159847
			public override TextObject IssueAlternativeSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=ltiz6e11}Let them know my companion will be meeting them shortly.", null);
				}
			}

			// Token: 0x17000F46 RID: 3910
			// (get) Token: 0x06004B7F RID: 19327 RVA: 0x0015B654 File Offset: 0x00159854
			public override bool IsThereLordSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000F47 RID: 3911
			// (get) Token: 0x06004B80 RID: 19328 RVA: 0x0015B658 File Offset: 0x00159858
			public override TextObject IssueQuestSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=qh1Ot0F9}They have {STOLEN_GOODS_SIZE} {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%}. They're asking {REQUESTED_PRICE}{GOLD_ICON}. You know that this is the best price you can find anywhere in this district.", null);
					textObject.SetTextVariable("STOLEN_GOODS_SIZE", this.StolenTradeGoodAmount);
					textObject.SetTextVariable("STOLEN_GOOD", this.StolenTradeGood.Name);
					textObject.SetTextVariable("REQUESTED_PRICE", this.StolenTradeGoodPrice);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17000F48 RID: 3912
			// (get) Token: 0x06004B81 RID: 19329 RVA: 0x0015B6BC File Offset: 0x001598BC
			public override TextObject IssueBriefByIssueGiver
			{
				get
				{
					return new TextObject("{=babDRxdu}I am trying to help some friends. They want a buyer for some goods, that, well, let's say that my friends might not have paid for these goods. These lads are camped close by, but would prefer not to come into town. You see?[if:convo_mocking_aristocratic][ib:hip]", null);
				}
			}

			// Token: 0x17000F49 RID: 3913
			// (get) Token: 0x06004B82 RID: 19330 RVA: 0x0015B6C9 File Offset: 0x001598C9
			public override TextObject IssueAcceptByPlayer
			{
				get
				{
					return new TextObject("{=rMySUGLu}I am interested. What are they selling?", null);
				}
			}

			// Token: 0x17000F4A RID: 3914
			// (get) Token: 0x06004B83 RID: 19331 RVA: 0x0015B6D6 File Offset: 0x001598D6
			public override TextObject IssueQuestSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=t1tNPPNf}I can go meet them and seal this deal myself.", null);
				}
			}

			// Token: 0x17000F4B RID: 3915
			// (get) Token: 0x06004B84 RID: 19332 RVA: 0x0015B6E3 File Offset: 0x001598E3
			public override TextObject IssueAlternativeSolutionResponseByIssueGiver
			{
				get
				{
					return new TextObject("{=ov0u6ahh}All right. It was a pleasure doing business with you.", null);
				}
			}

			// Token: 0x17000F4C RID: 3916
			// (get) Token: 0x06004B85 RID: 19333 RVA: 0x0015B6F0 File Offset: 0x001598F0
			public override TextObject IssueDiscussAlternativeSolution
			{
				get
				{
					return new TextObject("{=A2JWExWL}I hope our respective friends come to an agreement.", null);
				}
			}

			// Token: 0x17000F4D RID: 3917
			// (get) Token: 0x06004B86 RID: 19334 RVA: 0x0015B6FD File Offset: 0x001598FD
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=izuhKnXy}Purchase stolen goods from {ISSUE_GIVER.NAME}", null);
					textObject.SetCharacterProperties("ISSUE_GIVER", base.IssueOwner.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F4E RID: 3918
			// (get) Token: 0x06004B87 RID: 19335 RVA: 0x0015B721 File Offset: 0x00159921
			public override TextObject Description
			{
				get
				{
					TextObject textObject = new TextObject("{=3WFgPigk}{ISSUE_GIVER.NAME} wants to sell you stolen goods. The price is low because of the added risk.", null);
					textObject.SetCharacterProperties("ISSUE_GIVER", base.IssueOwner.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F4F RID: 3919
			// (get) Token: 0x06004B88 RID: 19336 RVA: 0x0015B748 File Offset: 0x00159948
			protected override TextObject AlternativeSolutionStartLog
			{
				get
				{
					TextObject textObject = new TextObject("{=riKyIyaa}{QUEST_GIVER.LINK}, a gang leader from {QUEST_GIVER_SETTLEMENT}, has offered you to sell {STOLEN_GOODS_SIZE} {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%} for half the normal price, because they were stolen... {?QUEST_GIVER.GENDER}She{?}He{\\?} says they are hidden in a remote location. You asked your companion to go buy the goods.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, false);
					textObject.SetTextVariable("QUEST_GIVER_SETTLEMENT", base.IssueOwner.CurrentSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("STOLEN_GOODS_SIZE", this.StolenTradeGoodAmount);
					textObject.SetTextVariable("STOLEN_GOOD", this.StolenTradeGood.Name);
					return textObject;
				}
			}

			// Token: 0x17000F50 RID: 3920
			// (get) Token: 0x06004B89 RID: 19337 RVA: 0x0015B7BC File Offset: 0x001599BC
			public override TextObject IssueAlternativeSolutionSuccessLog
			{
				get
				{
					TextObject textObject = new TextObject("{=XOB0SMXC}{COMPANION.LINK} has successfully offloaded the stolen goods. {?QUEST_GIVER.GENDER}She{?}He{\\?} returned to the party with {STOLEN_GOODS_SIZE} {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%}.", null);
					textObject.SetCharacterProperties("COMPANION", base.AlternativeSolutionHero.CharacterObject, false);
					textObject.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, false);
					textObject.SetTextVariable("STOLEN_GOODS_SIZE", this.StolenTradeGoodAmount);
					textObject.SetTextVariable("STOLEN_GOOD", this.StolenTradeGood.Name);
					return textObject;
				}
			}

			// Token: 0x17000F51 RID: 3921
			// (get) Token: 0x06004B8A RID: 19338 RVA: 0x0015B82B File Offset: 0x00159A2B
			protected override int CompanionSkillRewardXP
			{
				get
				{
					return 1000 + (int)(1250f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F52 RID: 3922
			// (get) Token: 0x06004B8B RID: 19339 RVA: 0x0015B840 File Offset: 0x00159A40
			protected override int AlternativeSolutionBaseDurationInDaysInternal
			{
				get
				{
					return (int)(7f + 10f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F53 RID: 3923
			// (get) Token: 0x06004B8C RID: 19340 RVA: 0x0015B855 File Offset: 0x00159A55
			public override int AlternativeSolutionBaseNeededMenCount
			{
				get
				{
					return 10;
				}
			}

			// Token: 0x06004B8D RID: 19341 RVA: 0x0015B859 File Offset: 0x00159A59
			public override ValueTuple<SkillObject, int> GetAlternativeSolutionSkill(Hero hero)
			{
				List<SkillObject> alternativeSolutionMeleeSkills = QuestHelper.GetAlternativeSolutionMeleeSkills();
				alternativeSolutionMeleeSkills.Add(DefaultSkills.Roguery);
				alternativeSolutionMeleeSkills.Add(DefaultSkills.Tactics);
				return new ValueTuple<SkillObject, int>(alternativeSolutionMeleeSkills.MaxBy(new Func<SkillObject, int>(hero.GetSkillValue)), 120);
			}

			// Token: 0x06004B8E RID: 19342 RVA: 0x0015B88E File Offset: 0x00159A8E
			public override bool AlternativeSolutionCondition(out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(MobileParty.MainParty.MemberRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004B8F RID: 19343 RVA: 0x0015B8B0 File Offset: 0x00159AB0
			protected override void AlternativeSolutionEndWithSuccessConsequence()
			{
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, this.RewardGold, false);
				this.RelationshipChangeWithIssueOwner = 10;
				base.IssueOwner.AddPower(5f);
				this.CounterOfferHero.AddPower(-5f);
				foreach (Hero hero in base.IssueOwner.CurrentSettlement.Notables.WhereQ((Hero notable) => notable.IsMerchant))
				{
					hero.AddPower(-3f);
				}
				MobileParty.MainParty.ItemRoster.AddToCounts(this.StolenTradeGood, this.StolenTradeGoodAmount);
				TraitLevelingHelper.OnIssueSolvedThroughAlternativeSolution(Hero.MainHero, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Calculating, 50)
				});
			}

			// Token: 0x06004B90 RID: 19344 RVA: 0x0015B9A4 File Offset: 0x00159BA4
			public override bool DoTroopsSatisfyAlternativeSolution(TroopRoster troopRoster, out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(troopRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004B91 RID: 19345 RVA: 0x0015B9BC File Offset: 0x00159BBC
			public GangLeaderNeedsToOffloadStolenGoodsIssue(Hero issueOwner, Settlement hideout) : base(issueOwner, CampaignTime.DaysFromNow(15f))
			{
				this._randomForStolenTradeGood = MBRandom.RandomInt(0, GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue.PossibleStolenItems.Length);
				this._issueHideout = hideout;
				Campaign.Current.BusyHideouts.Add(hideout);
			}

			// Token: 0x06004B92 RID: 19346 RVA: 0x0015B9F9 File Offset: 0x00159BF9
			protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
			{
				if (issueEffect == DefaultIssueEffects.IssueOwnerPower)
				{
					return -1f;
				}
				if (issueEffect == DefaultIssueEffects.SettlementSecurity)
				{
					return 1f;
				}
				return 0f;
			}

			// Token: 0x06004B93 RID: 19347 RVA: 0x0015BA1C File Offset: 0x00159C1C
			public override bool IssueStayAliveConditions()
			{
				return base.IssueOwner.CurrentSettlement.Town.Security < 90f && this.CounterOfferHero.IsActive && this.CounterOfferHero.CurrentSettlement == base.IssueSettlement && this._issueHideout != null && this._issueHideout.Hideout.IsInfested;
			}

			// Token: 0x06004B94 RID: 19348 RVA: 0x0015BA7F File Offset: 0x00159C7F
			protected override void CompleteIssueWithTimedOutConsequences()
			{
			}

			// Token: 0x06004B95 RID: 19349 RVA: 0x0015BA84 File Offset: 0x00159C84
			protected override void AfterIssueCreation()
			{
				this.CounterOfferHero = (base.IssueOwner.CurrentSettlement.Notables.FirstOrDefault((Hero x) => x != base.IssueOwner && x.IsMerchant) ?? base.IssueOwner.CurrentSettlement.Notables.FirstOrDefault<Hero>());
			}

			// Token: 0x06004B96 RID: 19350 RVA: 0x0015BAD4 File Offset: 0x00159CD4
			protected override void OnGameLoad()
			{
				if (MBSaveLoad.IsUpdatingGameVersion && MBSaveLoad.LastLoadedGameVersion < ApplicationVersion.FromString("v1.2.0", 54620))
				{
					Campaign.Current.IssueManager.DeactivateIssue(this);
				}
				if (MBSaveLoad.IsUpdatingGameVersion && MBSaveLoad.LastLoadedGameVersion < ApplicationVersion.FromString("v1.2.9", 54620) && !Campaign.Current.BusyHideouts.Contains(this._issueHideout))
				{
					Campaign.Current.BusyHideouts.Add(this._issueHideout);
				}
			}

			// Token: 0x06004B97 RID: 19351 RVA: 0x0015BB61 File Offset: 0x00159D61
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004B98 RID: 19352 RVA: 0x0015BB64 File Offset: 0x00159D64
			protected override QuestBase GenerateIssueQuest(string questId)
			{
				return new GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest(questId, base.IssueOwner, CampaignTime.DaysFromNow(20f), this.StolenTradeGood, this._issueHideout, this.StolenTradeGoodPrice, this.RewardGold, this.StolenTradeGoodAmount, this.CounterOfferHero);
			}

			// Token: 0x06004B99 RID: 19353 RVA: 0x0015BBAB File Offset: 0x00159DAB
			public override IssueBase.IssueFrequency GetFrequency()
			{
				return IssueBase.IssueFrequency.Common;
			}

			// Token: 0x06004B9A RID: 19354 RVA: 0x0015BBB0 File Offset: 0x00159DB0
			protected override bool CanPlayerTakeQuestConditions(Hero issueGiver, out IssueBase.PreconditionFlags flag, out Hero relationHero, out SkillObject skill)
			{
				flag = IssueBase.PreconditionFlags.None;
				relationHero = null;
				skill = null;
				if (issueGiver.GetRelationWithPlayer() < -10f)
				{
					flag |= IssueBase.PreconditionFlags.Relation;
					relationHero = issueGiver;
				}
				if (issueGiver.CurrentSettlement.MapFaction.IsAtWarWith(Hero.MainHero.MapFaction))
				{
					flag |= IssueBase.PreconditionFlags.AtWar;
				}
				if (Clan.PlayerClan == issueGiver.CurrentSettlement.OwnerClan)
				{
					flag |= IssueBase.PreconditionFlags.PlayerIsOwnerOfSettlement;
				}
				return flag == IssueBase.PreconditionFlags.None;
			}

			// Token: 0x06004B9B RID: 19355 RVA: 0x0015BC21 File Offset: 0x00159E21
			protected override void OnIssueFinalized()
			{
				Campaign.Current.BusyHideouts.Remove(this._issueHideout);
			}

			// Token: 0x0400198D RID: 6541
			private const int QuestDurationInDays = 20;

			// Token: 0x0400198E RID: 6542
			private static readonly string[] PossibleStolenItems = new string[]
			{
				"jewelry",
				"fur",
				"silver",
				"velvet"
			};

			// Token: 0x04001990 RID: 6544
			[SaveableField(20)]
			private readonly int _randomForStolenTradeGood;

			// Token: 0x04001991 RID: 6545
			[SaveableField(30)]
			private readonly Settlement _issueHideout;

			// Token: 0x04001992 RID: 6546
			private const int AlternativeSolutionMinimumTroopLevel = 2;

			// Token: 0x04001993 RID: 6547
			private const int CompanionRequiredSkillLevel = 120;
		}

		// Token: 0x02000623 RID: 1571
		public class GangLeaderNeedsToOffloadStolenGoodsIssueQuest : QuestBase
		{
			// Token: 0x06004B9E RID: 19358 RVA: 0x0015BC79 File Offset: 0x00159E79
			internal static void AutoGeneratedStaticCollectObjectsGangLeaderNeedsToOffloadStolenGoodsIssueQuest(object o, List<object> collectedObjects)
			{
				((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004B9F RID: 19359 RVA: 0x0015BC87 File Offset: 0x00159E87
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._stolenTradeGood);
				collectedObjects.Add(this._playerStartsQuestLog);
				collectedObjects.Add(this._counterOfferHero);
				collectedObjects.Add(this._questHideout);
			}

			// Token: 0x06004BA0 RID: 19360 RVA: 0x0015BCC0 File Offset: 0x00159EC0
			internal static object AutoGeneratedGetMemberValue_stolenTradeGood(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._stolenTradeGood;
			}

			// Token: 0x06004BA1 RID: 19361 RVA: 0x0015BCCD File Offset: 0x00159ECD
			internal static object AutoGeneratedGetMemberValue_stolenTradeGoodAmount(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._stolenTradeGoodAmount;
			}

			// Token: 0x06004BA2 RID: 19362 RVA: 0x0015BCDF File Offset: 0x00159EDF
			internal static object AutoGeneratedGetMemberValue_stolenTradeGoodPrice(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._stolenTradeGoodPrice;
			}

			// Token: 0x06004BA3 RID: 19363 RVA: 0x0015BCF1 File Offset: 0x00159EF1
			internal static object AutoGeneratedGetMemberValue_counterOfferGiven(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._counterOfferGiven;
			}

			// Token: 0x06004BA4 RID: 19364 RVA: 0x0015BD03 File Offset: 0x00159F03
			internal static object AutoGeneratedGetMemberValue_counterOfferGold(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._counterOfferGold;
			}

			// Token: 0x06004BA5 RID: 19365 RVA: 0x0015BD15 File Offset: 0x00159F15
			internal static object AutoGeneratedGetMemberValue_playerStartsQuestLog(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._playerStartsQuestLog;
			}

			// Token: 0x06004BA6 RID: 19366 RVA: 0x0015BD22 File Offset: 0x00159F22
			internal static object AutoGeneratedGetMemberValue_counterOfferHero(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._counterOfferHero;
			}

			// Token: 0x06004BA7 RID: 19367 RVA: 0x0015BD2F File Offset: 0x00159F2F
			internal static object AutoGeneratedGetMemberValue_talkedWithBanditLeader(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._talkedWithBanditLeader;
			}

			// Token: 0x06004BA8 RID: 19368 RVA: 0x0015BD41 File Offset: 0x00159F41
			internal static object AutoGeneratedGetMemberValue_isPayingForGoods(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._isPayingForGoods;
			}

			// Token: 0x06004BA9 RID: 19369 RVA: 0x0015BD53 File Offset: 0x00159F53
			internal static object AutoGeneratedGetMemberValue_isFightingForGoods(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._isFightingForGoods;
			}

			// Token: 0x06004BAA RID: 19370 RVA: 0x0015BD65 File Offset: 0x00159F65
			internal static object AutoGeneratedGetMemberValue_questHideout(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._questHideout;
			}

			// Token: 0x06004BAB RID: 19371 RVA: 0x0015BD72 File Offset: 0x00159F72
			internal static object AutoGeneratedGetMemberValue_playerHasTheGoods(object o)
			{
				return ((GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest)o)._playerHasTheGoods;
			}

			// Token: 0x17000F54 RID: 3924
			// (get) Token: 0x06004BAC RID: 19372 RVA: 0x0015BD84 File Offset: 0x00159F84
			public override bool IsRemainingTimeHidden
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000F55 RID: 3925
			// (get) Token: 0x06004BAD RID: 19373 RVA: 0x0015BD87 File Offset: 0x00159F87
			private CharacterObject BanditLeader
			{
				get
				{
					return this._questHideout.Culture.BanditChief;
				}
			}

			// Token: 0x17000F56 RID: 3926
			// (get) Token: 0x06004BAE RID: 19374 RVA: 0x0015BD9C File Offset: 0x00159F9C
			private TextObject PlayerStartsQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=uaYGZUDs}{QUEST_GIVER.LINK}, a gang leader from {QUEST_GIVER_SETTLEMENT}, has offered you to sell {STOLEN_GOODS_SIZE} {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%} for half the normal price, because they were stolen.. {?QUEST_GIVER.GENDER}She{?}He{\\?} says they are hidden in a remote location. You agreed to buy the goods.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("QUEST_GIVER_SETTLEMENT", base.QuestGiver.CurrentSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("STOLEN_GOOD", this._stolenTradeGood.Name);
					textObject.SetTextVariable("STOLEN_GOODS_SIZE", this._stolenTradeGoodAmount);
					return textObject;
				}
			}

			// Token: 0x17000F57 RID: 3927
			// (get) Token: 0x06004BAF RID: 19375 RVA: 0x0015BE13 File Offset: 0x0015A013
			private TextObject SuccessQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=mrNdB0Hh}You refused the {MERCHANT.LINK}'s request and kept the goods.", null);
					textObject.SetCharacterProperties("MERCHANT", this._counterOfferHero.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F58 RID: 3928
			// (get) Token: 0x06004BB0 RID: 19376 RVA: 0x0015BE37 File Offset: 0x0015A037
			private TextObject SuccessByGivingBackTheGoodsQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=jO9cGnCK}You bought the goods from the bandits and handed over them to the {MERCHANT.LINK}.", null);
					textObject.SetCharacterProperties("MERCHANT", this._counterOfferHero.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F59 RID: 3929
			// (get) Token: 0x06004BB1 RID: 19377 RVA: 0x0015BE5B File Offset: 0x0015A05B
			private TextObject FailBetrayQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=v1bkAxmK}You accepted {MERCHANT.LINK}'s request. You've handed over the goods.", null);
					textObject.SetCharacterProperties("MERCHANT", this._counterOfferHero.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F5A RID: 3930
			// (get) Token: 0x06004BB2 RID: 19378 RVA: 0x0015BE7F File Offset: 0x0015A07F
			private TextObject FailBetrayTakeGoodsQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=7q0vbVdN}You betrayed the gang leader and refused the {MERCHANT.LINK}'s request. The goods stayed with you.", null);
					textObject.SetCharacterProperties("MERCHANT", this._counterOfferHero.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F5B RID: 3931
			// (get) Token: 0x06004BB3 RID: 19379 RVA: 0x0015BEA3 File Offset: 0x0015A0A3
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=AtHjW2lY}Purchase stolen goods from {QUEST_GIVER.NAME}", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F5C RID: 3932
			// (get) Token: 0x06004BB4 RID: 19380 RVA: 0x0015BEC7 File Offset: 0x0015A0C7
			private TextObject FailLoseHideoutFightQuestLogText
			{
				get
				{
					return new TextObject("{=g7atkzxO}You failed to clear the hideout.", null);
				}
			}

			// Token: 0x17000F5D RID: 3933
			// (get) Token: 0x06004BB5 RID: 19381 RVA: 0x0015BED4 File Offset: 0x0015A0D4
			private TextObject FailTimeOutQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=JwNTcFLA}You failed to make the deal with {QUEST_GIVER.LINK}'s associates in time.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x06004BB6 RID: 19382 RVA: 0x0015BEF8 File Offset: 0x0015A0F8
			public GangLeaderNeedsToOffloadStolenGoodsIssueQuest(string questId, Hero questGiver, CampaignTime duration, ItemObject stolenTradeGood, Settlement questHideout, int stolenTradeGoodPrice, int rewardGold, int stolenGoodAmount, Hero counterOfferHero) : base(questId, questGiver, duration, rewardGold)
			{
				this._stolenTradeGood = stolenTradeGood;
				this._stolenTradeGoodPrice = stolenTradeGoodPrice;
				this._stolenTradeGoodAmount = stolenGoodAmount;
				this._counterOfferGold = MathF.Round((float)(questGiver.CurrentSettlement.Town.GetItemPrice(this._stolenTradeGood, null, false) * this._stolenTradeGoodAmount) * 0.4f);
				this._counterOfferHero = counterOfferHero;
				this._questHideout = questHideout;
				Campaign.Current.BusyHideouts.Add(questHideout);
				this.SetDialogs();
				base.InitializeQuestOnCreation();
				this.AddGameMenuOptions();
			}

			// Token: 0x17000F5E RID: 3934
			// (get) Token: 0x06004BB7 RID: 19383 RVA: 0x0015BF8C File Offset: 0x0015A18C
			private TextObject CancelSettlementOwnerChangedQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=0YwZsiT4}Your clan is now owner of the town from which the goods were stolen. As the lord of the settlement you cannot get involved in deals of this kind. Your agreement with {QUEST_GIVER.LINK} is canceled.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x06004BB8 RID: 19384 RVA: 0x0015BFB0 File Offset: 0x0015A1B0
			protected override void SetDialogs()
			{
				this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start", 100).NpcLine(new TextObject("{=iKYd8PQc}Excellent. I'll have the whereabouts of the goods delivered to you right away...[if:convo_nonchalant][ib:confident]", null), null, null).Condition(() => Hero.OneToOneConversationHero == base.QuestGiver).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).CloseDialog();
				this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss", 100).NpcLine(new TextObject("{=RmjvSKVq}My colleagues are waiting for your arrival. They won't be happy waiting too long with so many valuables at hand.", null), null, null).Condition(() => Hero.OneToOneConversationHero == base.QuestGiver).BeginPlayerOptions().PlayerOption(new TextObject("{=D4CsJMLE}Don't worry, I'll get there soon enough.", null), null).NpcLine(new TextObject("{=2D4EdZVK}All right, but if this falls through because you took too long, I won't be too happy with that.", null), null, null).PlayerOption(new TextObject("{=ErKDfLWJ}I have more urgent business to handle. I will get there when I can.", null), null).NpcLine(new TextObject("{=qLdchkGU}Yeah... Well, a lot can go wrong if you don't move on these things quickly.", null), null, null).EndPlayerOptions().CloseDialog();
				Campaign.Current.ConversationManager.AddDialogFlow(this.GetCounterOfferDialogFlow(), this);
				Campaign.Current.ConversationManager.AddDialogFlow(this.GetHideoutLeaderDialogFlow(), this);
				Campaign.Current.ConversationManager.AddDialogFlow(this.GetAfterHideoutMerchantDialogFlow(), this);
			}

			// Token: 0x17000F5F RID: 3935
			// (get) Token: 0x06004BB9 RID: 19385 RVA: 0x0015C0D4 File Offset: 0x0015A2D4
			private TextObject BeforeAttackHideoutQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=sVL8Z0lg}You met {QUEST_GIVER.LINK}'s associates near their hideout and demanded they turn over the goods to you, refusing to pay. They refused, and your only option now is to attack the hideout under cover of darkness and take the goods by force.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x06004BBA RID: 19386 RVA: 0x0015C0F8 File Offset: 0x0015A2F8
			private void QuestAcceptedConsequences()
			{
				base.StartQuest();
				this._playerStartsQuestLog = base.AddLog(this.PlayerStartsQuestLogText, true);
				this._questHideout.Hideout.IsSpotted = true;
				this._questHideout.IsVisible = true;
				base.AddTrackedObject(this._questHideout);
			}

			// Token: 0x06004BBB RID: 19387 RVA: 0x0015C147 File Offset: 0x0015A347
			protected override void InitializeQuestOnGameLoad()
			{
				this.SetDialogs();
				this.AddGameMenuOptions();
			}

			// Token: 0x06004BBC RID: 19388 RVA: 0x0015C155 File Offset: 0x0015A355
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004BBD RID: 19389 RVA: 0x0015C157 File Offset: 0x0015A357
			protected override void OnFinalize()
			{
				Campaign.Current.BusyHideouts.Remove(this._questHideout);
			}

			// Token: 0x06004BBE RID: 19390 RVA: 0x0015C170 File Offset: 0x0015A370
			private DialogFlow GetCounterOfferDialogFlow()
			{
				TextObject textObject = new TextObject("{=WJPAWHM9}A moment of your time, {?PLAYER.GENDER}ma'am{?}sir{\\?}. I hear you've been talking with a well-known scoundrel named {QUEST_GIVER.LINK}. A while ago, a caravan of mine carrying some {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%} was robbed. Now {?QUEST_GIVER.GENDER}she's{?}he's{\\?} going around offering to sell the exact same merchandise. The guards won't go beyond the walls to get it back, but you can. I will reward you, and you'll earn the gratitude of all law-abiding townsfolk.[if:convo_nonchalant][ib:normal2]", null);
				textObject.SetCharacterProperties("PLAYER", CharacterObject.PlayerCharacter, false);
				textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
				textObject.SetTextVariable("STOLEN_GOODS_SIZE", this._stolenTradeGoodAmount);
				textObject.SetTextVariable("STOLEN_GOOD", this._stolenTradeGood.Name);
				return DialogFlow.CreateDialogFlow("start", 125).NpcLine(textObject, null, null).Condition(() => this._counterOfferHero == Hero.OneToOneConversationHero && !this._talkedWithBanditLeader && !this._playerHasTheGoods).BeginPlayerOptions().PlayerOption(new TextObject("{=Fk9nVX8t}Yes... Well, I will see what I can do.", null), null).NpcLine(new TextObject("{=WotPuijV}That's the right decision. Thank you.[if:convo_calm_friendly][ib:closed]", null), null, null).CloseDialog().PlayerOption(new TextObject("{=1fXYQ7XG}My deals are none of your business, merchant.", null), null).NpcLine(new TextObject("{=u0pofzPq}Please reconsider. Whether you help me or not, I will make sure other merchants will hear of your decision.[if:convo_very_stern][ib:closed2]", null), null, null).CloseDialog().EndPlayerOptions().CloseDialog();
			}

			// Token: 0x06004BBF RID: 19391 RVA: 0x0015C25E File Offset: 0x0015A45E
			protected override void OnTimedOut()
			{
				base.AddLog(this.FailTimeOutQuestLogText, false);
			}

			// Token: 0x06004BC0 RID: 19392 RVA: 0x0015C270 File Offset: 0x0015A470
			private void AddGameMenuOptions()
			{
				TextObject optionText = new TextObject("{=wbSXI6iq}Approach to the meeting point", null);
				base.AddGameMenuOption("hideout_place", "talk_to_boss", optionText, new GameMenuOption.OnConditionDelegate(this.game_menu_approach_meeting_on_condition), new GameMenuOption.OnConsequenceDelegate(this.game_menu_approach_meeting_on_consequence), false, 2);
			}

			// Token: 0x06004BC1 RID: 19393 RVA: 0x0015C2B4 File Offset: 0x0015A4B4
			private DialogFlow GetHideoutLeaderDialogFlow()
			{
				TextObject banditBrief = new TextObject("{=!}{BANDIT_BRIEF}", null);
				TextObject banditFirstInteraction = new TextObject("{=2dWvwc0T}You must be the nice {?PLAYER.GENDER}lady{?}lord{\\?} who {QUEST_GIVER.NAME} has been telling us about. We have been expecting you. The goods are nearby. I will tell my friends to bring them out as soon as you pay up.", null);
				banditFirstInteraction.SetCharacterProperties("PLAYER", CharacterObject.PlayerCharacter, false);
				banditFirstInteraction.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
				TextObject banditSecondInteraction = new TextObject("{=n17USCaH}Well well... Do you have our money yet?", null);
				TextObject textObject = new TextObject("{=hXmmofDN}Here are the denars. You can tell your friends to bring out the {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%}.", null);
				textObject.SetTextVariable("STOLEN_GOODS_SIZE", this._stolenTradeGoodAmount);
				textObject.SetTextVariable("STOLEN_GOOD", this._stolenTradeGood.Name);
				TextObject text = new TextObject("{=Bvb0AmW7}Unfortunately, I do not have enough denars on me.", null);
				TextObject npcText = new TextObject("{=7kTipmjp}Then why are you here? We're not the sort who does business on credit. Come back when you have the money.", null);
				return DialogFlow.CreateDialogFlow("start", 125).NpcLine(banditBrief, null, null).Condition(delegate
				{
					banditBrief.SetTextVariable("BANDIT_BRIEF", (!this._talkedWithBanditLeader) ? banditFirstInteraction : banditSecondInteraction);
					return this.BanditLeader == CharacterObject.OneToOneConversationCharacter && Game.Current.GameStateManager.ActiveState is MapState && Settlement.CurrentSettlement == this._questHideout;
				}).Consequence(delegate
				{
					this._talkedWithBanditLeader = true;
				}).NpcLine(banditSecondInteraction, null, null).Condition(() => this.BanditLeader == CharacterObject.OneToOneConversationCharacter && this._talkedWithBanditLeader && Game.Current.GameStateManager.ActiveState is MapState).BeginPlayerOptions().PlayerOption(textObject, null).ClickableCondition(delegate(out TextObject explanation)
				{
					bool result = false;
					if (Hero.MainHero.Gold >= this._stolenTradeGoodPrice)
					{
						explanation = new TextObject("{=!}{GOLD_AMOUNT}{GOLD_ICON}", null);
						explanation.SetTextVariable("GOLD_AMOUNT", this._stolenTradeGoodPrice);
						result = true;
					}
					else
					{
						explanation = new TextObject("{=YuLLsAUb}You don't have {GOLD_AMOUNT}{GOLD_ICON}.", null);
						explanation.SetTextVariable("GOLD_AMOUNT", this._stolenTradeGoodPrice);
					}
					return result;
				}).NpcLine(new TextObject("{=21Y4tWE9}Good, good. All the best to you, friend.", null), null, null).Consequence(delegate
				{
					GiveGoldAction.ApplyForQuestBetweenCharacters(Hero.MainHero, null, this._stolenTradeGoodPrice, false);
					this._isPayingForGoods = true;
					this._playerHasTheGoods = true;
				}).CloseDialog().PlayerOption(new TextObject("{=H7FpMR0O}I'm not buying them from you, thief. Bring them out now.", null), null).NpcLine(new TextObject("{=M8j6J8aN}Really? Very well, I'll send word to my lads that you intended to take our loot by force. They'll get things ready for you, have no fear. Just maybe not in the way you're hoping...", null), null, null).Consequence(delegate
				{
					this.AddLog(this.BeforeAttackHideoutQuestLogText, false);
					this._isFightingForGoods = true;
				}).CloseDialog().PlayerOption(text, null).Condition(() => Hero.MainHero.Gold < this._stolenTradeGoodPrice).NpcLine(npcText, null, null).CloseDialog().EndPlayerOptions().CloseDialog();
			}

			// Token: 0x06004BC2 RID: 19394 RVA: 0x0015C488 File Offset: 0x0015A688
			private DialogFlow GetAfterHideoutMerchantDialogFlow()
			{
				TextObject textObject = new TextObject("{=8nq0TbMZ}{?PLAYER.GENDER}Ma'am{?}Sir{\\?}! I saw your party from a distance. I hope you don't mind me catching up to you. I am glad to see you safe - and, from the looks of it, in possession of some fine new goods. Please tell me, would they be mine?", null);
				textObject.SetCharacterProperties("PLAYER", CharacterObject.PlayerCharacter, false);
				TextObject textObject2 = new TextObject("{=Utq4svjd}Splendid. I will be sure that everyone in {MERCHANT_TOWN} hears of your honesty.", null);
				textObject2.SetTextVariable("MERCHANT_TOWN", base.QuestGiver.CurrentSettlement.EncyclopediaLinkWithName);
				TextObject textObject3 = new TextObject("{=dtghhz46}Well... You have swords. You can do what you like. Just don't expect anyone in {MERCHANT_TOWN} to think well of you. Good day, {?PLAYER.GENDER}ma'am{?}sir{\\?}.", null);
				textObject3.SetTextVariable("MERCHANT_TOWN", base.QuestGiver.CurrentSettlement.EncyclopediaLinkWithName);
				return DialogFlow.CreateDialogFlow("start", 125).NpcLine(textObject, null, null).Condition(() => Settlement.CurrentSettlement == this._questHideout && this._counterOfferHero == Hero.OneToOneConversationHero).BeginPlayerOptions().PlayerOption(new TextObject("{=peUxzLsY}\"Your\" goods? These are my goods now.", null), null).NpcLine(textObject3, null, null).Consequence(delegate
				{
					if (this._isPayingForGoods)
					{
						this.SucceedQuestByPayingAndKeepingTheGoods();
						return;
					}
					this.FailQuestByKeepingTheGoods();
				}).CloseDialog().PlayerOption(new TextObject("{=1lOSJ29M}Yes, they are here. Tell your men to come pick them up.", null), null).NpcLine(textObject2, null, null).Consequence(delegate
				{
					if (this._isPayingForGoods)
					{
						this.SucceedQuestByPayingAndGivingTheGoodsBack();
						return;
					}
					this.FailQuestByGivingBackTheGoods();
				}).CloseDialog().EndPlayerOptions().CloseDialog();
			}

			// Token: 0x06004BC3 RID: 19395 RVA: 0x0015C594 File Offset: 0x0015A794
			private void SucceedQuestByPayingAndKeepingTheGoods()
			{
				base.AddLog(this.SuccessQuestLogText, false);
				TraitLevelingHelper.OnIssueSolvedThroughQuest(Hero.MainHero, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Calculating, 100)
				});
				MobileParty.MainParty.ItemRoster.AddToCounts(this._stolenTradeGood, this._stolenTradeGoodAmount);
				base.QuestGiver.AddPower(5f);
				this._counterOfferHero.AddPower(-5f);
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, 10, true, true);
				foreach (Hero gainedRelationWith in base.QuestGiver.CurrentSettlement.Notables.WhereQ((Hero notable) => notable.IsMerchant))
				{
					ChangeRelationAction.ApplyPlayerRelation(gainedRelationWith, -3, true, true);
				}
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004BC4 RID: 19396 RVA: 0x0015C690 File Offset: 0x0015A890
			private void SucceedQuestByPayingAndGivingTheGoodsBack()
			{
				base.AddLog(this.SuccessByGivingBackTheGoodsQuestLogText, false);
				GiveGoldAction.ApplyForQuestBetweenCharacters(this._counterOfferHero, Hero.MainHero, this._counterOfferGold, false);
				TraitLevelingHelper.OnIssueSolvedThroughQuest(Hero.MainHero, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Calculating, 150)
				});
				base.QuestGiver.AddPower(5f);
				this._counterOfferHero.AddPower(5f);
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, 10, true, true);
				foreach (Hero gainedRelationWith in base.QuestGiver.CurrentSettlement.Notables.WhereQ((Hero notable) => notable != base.QuestGiver))
				{
					ChangeRelationAction.ApplyPlayerRelation(gainedRelationWith, 3, true, true);
				}
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004BC5 RID: 19397 RVA: 0x0015C774 File Offset: 0x0015A974
			private void FailQuestByKeepingTheGoods()
			{
				base.QuestGiver.AddPower(-5f);
				this._counterOfferHero.AddPower(-5f);
				TraitLevelingHelper.OnIssueSolvedThroughQuest(Hero.MainHero, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Calculating, 100)
				});
				MobileParty.MainParty.ItemRoster.AddToCounts(this._stolenTradeGood, this._stolenTradeGoodAmount);
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, -5, true, true);
				foreach (Hero gainedRelationWith in base.QuestGiver.CurrentSettlement.Notables.WhereQ((Hero notable) => notable.IsMerchant))
				{
					ChangeRelationAction.ApplyPlayerRelation(gainedRelationWith, -3, true, true);
				}
				base.CompleteQuestWithBetrayal(this.FailBetrayTakeGoodsQuestLogText);
			}

			// Token: 0x06004BC6 RID: 19398 RVA: 0x0015C868 File Offset: 0x0015AA68
			private void FailQuestByGivingBackTheGoods()
			{
				GiveGoldAction.ApplyForQuestBetweenCharacters(this._counterOfferHero, Hero.MainHero, this._counterOfferGold, false);
				base.QuestGiver.AddPower(-5f);
				this._counterOfferHero.AddPower(5f);
				TraitLevelingHelper.OnIssueSolvedThroughQuest(Hero.MainHero, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, 100)
				});
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, -5, true, true);
				foreach (Hero gainedRelationWith in base.QuestGiver.CurrentSettlement.Notables.WhereQ((Hero notable) => notable != base.QuestGiver))
				{
					ChangeRelationAction.ApplyPlayerRelation(gainedRelationWith, 3, true, true);
				}
				base.CompleteQuestWithBetrayal(this.FailBetrayQuestLogText);
			}

			// Token: 0x06004BC7 RID: 19399 RVA: 0x0015C944 File Offset: 0x0015AB44
			private void FailQuestByLosingHideoutBattle()
			{
				base.QuestGiver.AddPower(-5f);
				this._counterOfferHero.AddPower(-5f);
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, -5, true, true);
				base.CompleteQuestWithFail(this.FailLoseHideoutFightQuestLogText);
			}

			// Token: 0x06004BC8 RID: 19400 RVA: 0x0015C984 File Offset: 0x0015AB84
			protected override void RegisterEvents()
			{
				CampaignEvents.OnSessionLaunchedEvent.AddNonSerializedListener(this, new Action<CampaignGameStarter>(this.OnSessionStarted));
				CampaignEvents.GameMenuOpened.AddNonSerializedListener(this, new Action<MenuCallbackArgs>(this.GameMenuOpened));
				CampaignEvents.OnSettlementLeftEvent.AddNonSerializedListener(this, new Action<MobileParty, Settlement>(this.OnSettlementLeft));
				CampaignEvents.OnHideoutBattleCompletedEvent.AddNonSerializedListener(this, new Action<BattleSideEnum, HideoutEventComponent>(this.OnHideoutBattleCompleted));
				CampaignEvents.OnSettlementOwnerChangedEvent.AddNonSerializedListener(this, new Action<Settlement, bool, Hero, Hero, Hero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail>(this.OnSettlementOwnerChanged));
				CampaignEvents.MapEventStarted.AddNonSerializedListener(this, new Action<MapEvent, PartyBase, PartyBase>(this.OnMapEventStarted));
			}

			// Token: 0x06004BC9 RID: 19401 RVA: 0x0015CA1C File Offset: 0x0015AC1C
			private void OnSessionStarted(CampaignGameStarter campaignGameStarter)
			{
				if (MBSaveLoad.IsUpdatingGameVersion && MBSaveLoad.LastLoadedGameVersion < ApplicationVersion.FromString("v1.2.9", 54620))
				{
					if (!Campaign.Current.BusyHideouts.Contains(this._questHideout))
					{
						Campaign.Current.BusyHideouts.Add(this._questHideout);
						return;
					}
					base.CompleteQuestWithCancel(null);
					Campaign.Current.BusyHideouts.Add(this._questHideout);
				}
			}

			// Token: 0x06004BCA RID: 19402 RVA: 0x0015CA94 File Offset: 0x0015AC94
			private void OnMapEventStarted(MapEvent mapEvent, PartyBase attackerParty, PartyBase defenderParty)
			{
				if (mapEvent.MapEventSettlement == this._questHideout && attackerParty == PartyBase.MainParty)
				{
					this._isFightingForGoods = true;
				}
			}

			// Token: 0x06004BCB RID: 19403 RVA: 0x0015CAB3 File Offset: 0x0015ACB3
			private void OnSettlementOwnerChanged(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
			{
				if (settlement == base.QuestGiver.CurrentSettlement && newOwner == Hero.MainHero)
				{
					base.CompleteQuestWithCancel(this.CancelSettlementOwnerChangedQuestLogText);
				}
			}

			// Token: 0x06004BCC RID: 19404 RVA: 0x0015CAD8 File Offset: 0x0015ACD8
			private void OnHideoutBattleCompleted(BattleSideEnum winnerSide, HideoutEventComponent hideoutEventComponent)
			{
				if (hideoutEventComponent.MapEvent.PlayerSide != winnerSide)
				{
					this.FailQuestByLosingHideoutBattle();
					return;
				}
				if (hideoutEventComponent.MapEvent.MapEventSettlement == this._questHideout)
				{
					this._playerHasTheGoods = true;
					TextObject textObject = new TextObject("{=9bFAsGmp}You have cleared the hideout. Your men found the {.%}{?(STOLEN_GOODS_SIZE > 1)}{PLURAL(STOLEN_GOOD)}{?}{STOLEN_GOOD}{\\?}{.%} stashed nearby.", null);
					textObject.SetTextVariable("STOLEN_GOODS_SIZE", this._stolenTradeGoodAmount);
					textObject.SetTextVariable("STOLEN_GOOD", this._stolenTradeGood.Name);
					MBInformationManager.AddQuickInformation(textObject, 0, null, "");
				}
			}

			// Token: 0x06004BCD RID: 19405 RVA: 0x0015CB54 File Offset: 0x0015AD54
			private void GameMenuOpened(MenuCallbackArgs args)
			{
				if (Settlement.CurrentSettlement == this._questHideout && !this._isFightingForGoods)
				{
					GameTexts.SetVariable("HIDEOUT_DESCRIPTION", "{=b14v853a}As you approach the gang's camp, you can see a single man out in the open waiting for you, pacing and kicking stones around.");
				}
			}

			// Token: 0x06004BCE RID: 19406 RVA: 0x0015CB7C File Offset: 0x0015AD7C
			private void OnSettlementLeft(MobileParty party, Settlement settlement)
			{
				if (party == MobileParty.MainParty)
				{
					if (settlement == this._questHideout)
					{
						if (this._playerHasTheGoods)
						{
							CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, null, false, false, false, false, false, false), new ConversationCharacterData(this._counterOfferHero.CharacterObject, null, false, false, false, false, false, false));
							return;
						}
					}
					else if (settlement == this._counterOfferHero.CurrentSettlement && !this._counterOfferGiven)
					{
						CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, null, false, false, false, false, false, false), new ConversationCharacterData(this._counterOfferHero.CharacterObject, null, false, false, false, false, false, false));
						this._counterOfferGiven = true;
					}
				}
			}

			// Token: 0x06004BCF RID: 19407 RVA: 0x0015CC20 File Offset: 0x0015AE20
			private void game_menu_approach_meeting_on_consequence(MenuCallbackArgs args)
			{
				CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, null, false, false, false, false, false, false), new ConversationCharacterData(this.BanditLeader, null, false, false, false, false, false, false));
			}

			// Token: 0x06004BD0 RID: 19408 RVA: 0x0015CC55 File Offset: 0x0015AE55
			private bool game_menu_approach_meeting_on_condition(MenuCallbackArgs args)
			{
				args.optionLeaveType = GameMenuOption.LeaveType.Conversation;
				args.OptionQuestData = GameMenuOption.IssueQuestFlags.ActiveIssue;
				return Settlement.CurrentSettlement == this._questHideout && !this._isFightingForGoods && !this._isPayingForGoods;
			}

			// Token: 0x06004BD1 RID: 19409 RVA: 0x0015CC88 File Offset: 0x0015AE88
			public override void OnHeroCanHaveQuestOrIssueInfoIsRequested(Hero hero, ref bool result)
			{
				if (hero == this._counterOfferHero)
				{
					result = false;
				}
			}

			// Token: 0x04001994 RID: 6548
			[SaveableField(105)]
			private readonly ItemObject _stolenTradeGood;

			// Token: 0x04001995 RID: 6549
			[SaveableField(106)]
			private readonly int _stolenTradeGoodAmount;

			// Token: 0x04001996 RID: 6550
			[SaveableField(107)]
			private readonly int _stolenTradeGoodPrice;

			// Token: 0x04001997 RID: 6551
			[SaveableField(109)]
			private bool _counterOfferGiven;

			// Token: 0x04001998 RID: 6552
			[SaveableField(111)]
			private readonly int _counterOfferGold;

			// Token: 0x04001999 RID: 6553
			[SaveableField(112)]
			private JournalLog _playerStartsQuestLog;

			// Token: 0x0400199A RID: 6554
			[SaveableField(113)]
			private readonly Hero _counterOfferHero;

			// Token: 0x0400199B RID: 6555
			[SaveableField(114)]
			private bool _talkedWithBanditLeader;

			// Token: 0x0400199C RID: 6556
			[SaveableField(115)]
			private bool _isPayingForGoods;

			// Token: 0x0400199D RID: 6557
			[SaveableField(116)]
			private bool _isFightingForGoods;

			// Token: 0x0400199E RID: 6558
			[SaveableField(117)]
			private readonly Settlement _questHideout;

			// Token: 0x0400199F RID: 6559
			[SaveableField(118)]
			private bool _playerHasTheGoods;
		}

		// Token: 0x02000624 RID: 1572
		public class GangLeaderNeedsToOffloadStolenGoodsIssueTypeDefiner : SaveableTypeDefiner
		{
			// Token: 0x06004BDA RID: 19418 RVA: 0x0015CD3E File Offset: 0x0015AF3E
			public GangLeaderNeedsToOffloadStolenGoodsIssueTypeDefiner() : base(460000)
			{
			}

			// Token: 0x06004BDB RID: 19419 RVA: 0x0015CD4B File Offset: 0x0015AF4B
			protected override void DefineClassTypes()
			{
				base.AddClassDefinition(typeof(GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssue), 1, null);
				base.AddClassDefinition(typeof(GangLeaderNeedsToOffloadStolenGoodsIssueBehavior.GangLeaderNeedsToOffloadStolenGoodsIssueQuest), 2, null);
			}
		}
	}
}
